<template>
	<view>
		<view class="list-box">
			<view class="item-box" v-for="(item, key) in goodsList" @click="gotoDetail(item.id)">
				<view class="row-box title-box">
					<view style="width: 80%;">{{item.companyName}}</view>
					<view style="width: 20%;text-align: right;">
						{{item.statusDesc}}
					</view>
				</view>
				<view class="row-box date-box">
					<view style="width: 60%;">门店：{{item.shopName}}</view>
					<view style="width: 40%;text-align: right;">{{item.createTime}}</view>
				</view>
				
				<!-- 基本信息 -->
				<view class="info-box row-box">
					<view>
						<image style="width: 120rpx;height: 120rpx;" :src="item.fileUrls[0]"></image>
					</view>
					<view style="margin-left: 20rpx;">
						<view style="font-size: 32rpx;font-weight: 900;">{{item.modelName}}</view>
						<view>{{specsTran(item.specs)}}</view>
					</view>
				</view>
				
				<view style="border-top: #c0c4cc 1px solid;"></view>
				
				<view class="row-box" style="padding-top:16rpx;">
					<view class="center-box">
						<image style="width: 40rpx;height: 40rpx;" src="../../static/img/saoma.png"></image>
					</view>
					<view style="margin-left: 20rpx;font-size: 28rpx;">回收码：{{item.code ? item.code : '无'}}</view>
				</view>
			</view>
		</view>
		
		<view @click="nextPage()">
			<u-divider :text="hasNextPage() ? '加载更多':'没有更多了'"></u-divider>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: [],
				type: undefined,
				total: 0,
				queryParams: {
					pageNum: 1,
					pageSize: 20
				}
			}
		},
		onLoad(e) {
			console.log("当前类型: ",e);
			this.type = e.type
			this.getGoodsList();
		},
		methods: {
			getGoodsList() {
				this.$request("/appRecoverApi/order/queryOrderListByRecycle", "get", {status: this.type}).then(res => {
					this.goodsList.push(...res.rows);
					this.total = res.total
				})
			},
			specsTran(e) {
				if(e){
					return e.replaceAll(",", " ");
				}
				return "";
			},
			//详情
			gotoDetail(id) {
				uni.navigateTo({
					url: "/pages/store/inquiry/details?id=" + id,
				})
			},
			/* 加载下一页 */
			nextPage() {
				console.log("加载下一页")
				this.queryParams.pageNum++;
				if(this.hasNextPage())
					this.getList();
			},
			/* 是否还有下一页 */
			hasNextPage() {
				return this.goodsList.length < this.total;
			},
		}
	}
</script>

<style scoped lang="scss">
	.list-box {
		.item-box {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 20rpx;
			margin: 30rpx;
			line-height: 60rpx;
			.title-box {
				font-size: 32rpx;
				font-weight: 600;
			}
			.date-box {
				font-size: 22rpx;
			}
			.info-box {
				margin-top: 20rpx;
			}
		}
	}
</style>
